﻿@{
    ViewBag.Title = "在线空投快传";
    ViewBag.keywords = "空投快传";
    ViewBag.description = "AirPortal（空投快传）是一个可以跨设备传输文件的网站。只要您的设备联网，您就可以通过它在任意系统、任意设备间传输文件。无需登录或注册，只需打开空投快传、直接上传文件、记住所给的取件码或直接扫描二维码即可在另一台设备上下载文件。";
    var host = Appsettings.app("BaseFile:HostUrl");
}
@section Styles{
<style>
    .layui-layer-demo {
        background-color: red;
    }

    .content-left-aligned {
        height: 200px;
        line-height: 1.5;
        margin: 10px auto;
        max-width: 80%;
        text-align: left;
        width: 285px;
    }

    .layui-layer-btn0 a {
        border-color: #1E9FFF !important;
        background-color: #1E9FFF !important;
        color: #fff !important;
    }

    #upload-success-box {
        padding: 10px 15px;
        width: calc(100% - 30px);
        line-height: 25px;
    }

    .popup-title {
        color: var(--txt-b-pure);
        font-size: 18px;
        margin: 0 0 20px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #receiveCode {
        cursor: text;
        color:#0099ff;
        font-size: 36px;
        font-weight: 700;
        letter-spacing: 10px;
        line-height: 30px;
        padding-left: 10px;
        -webkit-user-select: text;
        user-select: text;
    }


    .warn.for-textarea {
        border-top-left-radius: 10px;
        border-top-right-radius: 10px;
        margin: 0 auto;
    }

    .warn {
        background-color: rgba(235,0,60,.05) !important;
        color: #eb003c !important;
        cursor: default;
        padding: 10px 15px;
        text-align: left;
        word-break: break-word;
    }

    .tip {
        color: var(--b-alpha-50);
        overflow: hidden;
        padding: 0 20px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .receive-input {
        color: var(--theme-color);
        font-size: 36px;
        letter-spacing: 10px;
        margin-bottom: 20px;
        padding: 15px 15px 15px 25px;
        position: relative;
        text-align: center;
        width: 200px;
    }

    .input {
        background-color: transparent;
        border: none;
        border-bottom-color: currentcolor;
        border-bottom-style: none;
        border-bottom-width: medium;
        border-bottom: 2px solid var(--b-alpha-10);
        border-radius: 0;
        transition: all .25s;
    }

    .popup-box {
        padding: 15px;
    }
</style>
}

<div style="min-height:600px;">
     <div id="text-received-warn" class="warn for-textarea">文本由用户上传。如果文本中含有网址，确保您信任文本的上传者，并知道网址的用途，否则不要打开。如果内容有害或违法，请<a id="report">向我们举报</a>。</div>
    <textarea class="layui-textarea" id="content">@ViewBag.data</textarea>
    <div style="margin:5px 0;"></div>
    <a class="layui-btn" id="send">发送</a>
    <a class="layui-btn layui-btn-danger" id="accept">接收</a>
</div>

<div id="content1" style="display:none;">
    <div class="content-left-aligned">严禁上传违反中国大陆法律法规的文件（包括但不限于：内容涉及色情、低俗、政治敏感、翻墙、暴力、恶意软件、诈骗、外挂、贩卖公民隐私的文件）。<strong>上传这些类型的文件将导致您的账号或 IP 地址被永久封禁，并可能被公安机关依法追究法律责任。</strong></div>
</div>

<div id="content3" style="display:none;">
    <div id="code-box" class="popup-box">
        <span id="close-btn-1663051541437" class="close-btn" tabindex="0" role="button" aria-label="关闭"></span>
        <p class="popup-title">
            <label for="code-input">请输入取件码</label>
        </p>
        <p class="tip">发送文件后就会获得取件码</p>
        <p></p>
        <div>
            <input id="codeInput" class="layui-input" type="tel" autocomplete="off" inputmode="numeric">
        </div>
    </div>
</div>

<div id="content4" style="display:none;">
    <div id="text-received-box" class="popup-box slide-in-from-right">
        <span class="close-btn" id="close-btn-1663043994839" tabindex="0" role="button" aria-label="关闭"></span>
        <p class="popup-title">接收到文本</p>
        <div id="text-received-warn" class="warn for-textarea">文本由用户上传。如果文本中含有网址，确保您信任文本的上传者，并知道网址的用途，否则不要打开。如果内容有害或违法，请<a id="report">向我们举报</a>。</div>
        <textarea id="text-received-view" class="has-warn" style="height: 129px;"></textarea>
        <button id="text-received-btn" class="popup-main-btn" type="button">复制</button>
    </div>
</div>

@section Scripts {
<script>
        layui.config({ base: '@host/js/' }).use('common',function(){ $=layui.jquery;
         let area_input = document.getElementById('content');

         $("#send").bind("click", function () {
             try {
                 var inptxt = area_input.value;
                 if (inptxt === undefined || inptxt === '' || inptxt === null) { layer.msg("内容不能为空.", { icon: 2 }); return; }
                 
                 layer.open({title:"警告", 
                 type: 1,icon:3, closeBtn: 0, 
                 anim: 2,shadeClose: false, 
                 content: $('#content1').html() ,btn: ['同意并继续', '放弃上传']
                 ,yes: function(index){
                     layer.close(index);
                     
              $.ajax({
                   url: '@host/air/send', type: 'post',
                   data: { content:inptxt },
                   success: function (res) {
                        var data=JSON.parse(res);
                       if(data.Code==200){
                           layer.open({ title: false, type: 1,icon:3, closeBtn: 0, anim: 2,shadeClose: false, content:'<div id="upload-success-box" class="popup-box slide-in-from-right"><p class="popup-title">文件已成功发送</p><p>您的取件码</p><p id="receiveCode">'+data.Data+'</p><p>接收文件时，请输入该6位数取件码</p></div>' ,btn: ['完成']
                           ,yes: function(index){
                               layer.close(index);
                               area_input.value="";
                           }
                           });
                       }
                       else{
                      layer.msg(data.Message, { icon: 2 });
                       }
                   }
               });
                 }
                 });
             } catch (err) {
                 console.log(err)
                 layer.msg("提交失败", { icon: 2 });
             }
         });

         $("#accept").bind("click", function () {
             try {
              var inptxt = area_input.value;

              layer.prompt({title: '请输入取件码，并确认', formType: 3}, function(pass, index){
                  layer.close(index);
                  if (pass === undefined || pass === '' || pass === null) { layer.msg("请输入取件码.", { icon: 2,time:1500 }); return; }
                  
                  $.ajax({
                   url: '@host/air/accept', type: 'post',
                   data: { code:pass },
                   success: function (res) {
                        var data=JSON.parse(res);
                       if(data.Code==200){
                            layer.close(index);
                            area_input.value=data.Data;
                       }
                       else{
                           layer.msg(data.Message, { icon: 2 });
                       }
                   }
               });
                  
                 
              });
             } 
             catch (err) {
                 console.log(err);
                 layer.msg("接收失败", { icon: 2 });
                  }
              });
         });
</script>
}